#ifndef _YL_SESSION_DATA_
#define _YL_SESSION_DATA_

#include "ylLogMessage.h"
#include "ylLogMessageTemplate.h"
#include <cliext/hash_map>

namespace yoctolog_viewer
{
	ref class LogMessageClass;
	ref class CallstackEntry;

	[System::SerializableAttribute]
	public ref class SessionData: public ISerializable
	{
	public:
		SessionData();
		~SessionData();

		// Message templates
		void AddMessageTemplate(unsigned int uiID, LogMessageTemplate ^pTemplate);
		LogMessageTemplate ^GetMessageTemplate(unsigned int uiID) { if( m_mapMessageTemplates->ContainsKey(uiID) ) return m_mapMessageTemplates[uiID]; return nullptr; }

		// Messages
		LogMessage ^GetMessage(unsigned int uiID);
		void AddMessage(LogMessage ^pMessage);

		// Serialization
		virtual void GetObjectData(System::Runtime::Serialization::SerializationInfo ^info, System::Runtime::Serialization::StreamingContext context);
		SessionData(System::Runtime::Serialization::SerializationInfo ^info, System::Runtime::Serialization::StreamingContext context);

		// IDs
		unsigned int GetNextID() { return m_uiCurrentID++; }

		property System::String ^	RemoteAddress;
		property System::String ^	ComputerName;
		property System::DateTime ^	StartedDateTime;

		property System::Int32		TotalBytesRead;
		property System::Int32		TotalBytesProcessed;
		property System::Int32		TotalMsgsProcessed;

		// TODO: Make private
		System::Collections::Generic::Dictionary<System::String ^, LogMessageGroup ^> ^	m_mapGroups;
		System::Collections::Generic::Dictionary<unsigned char, LogMessageClass ^> ^	m_mapMessageClasses;
		System::Collections::Generic::Dictionary<unsigned int, CallstackEntry ^> ^		m_mapCallstackEntries;

	private:
		System::Collections::Generic::Dictionary<unsigned int, LogMessageTemplate ^> ^	m_mapMessageTemplates;
		System::Collections::Generic::Dictionary<unsigned int, LogMessage ^> ^			m_mapMessages;


		unsigned int			m_uiCurrentID;

	};

}

#endif